/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dsw2.biblioteca.dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.its.dsw2.biblioteca.Libro;

/**
 *
 * @author chava
 */
@Stateless
public class LibroDao extends AbstractDao<Libro> implements LibroDaoLocal {
    @PersistenceContext(unitName = "Biblioteca-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public LibroDao() {
        super(Libro.class);
    }
    @Override
      public boolean FindDuplecity(Libro book){
       Query q=em.createNamedQuery("Libro.findByIsbn") ;
       q.setParameter("isbn", book.getIsbn());
       return !q.getResultList().isEmpty();
       
    }
}
